<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>
			Flip
		</title><!-- Help IE with utf8; thank you, Glards! -->

		<style type="text/css">
textarea { font-family: "Arial Unicode MS", Batang }
		</style>
<script language="JavaScript" type="text/javascript">
function flip() {
	var original = document.f.original.value
	// var result = flipString(original.toLowerCase());
	var result = flipString(original);
	document.f.flipped.value = result;
}

function flipChar(c) {
	var result = flipTable[c]
	if (result == undefined)
		result = flipTable[c.toLowerCase()]
	if (result == undefined)
		result = c
	return result
}

function flipString(aString) {
	var last = aString.length - 1;
	//Thanks to Brook Monroe for the
	//suggestion to use Array.join
	var result = new Array(aString.length)
	for (var i = last; i >= 0; --i) {
		result[last - i] = flipChar(aString.charAt(i))
	}
	return result.join('')
}

var flipTable = {
	'a' : '\u0250',
	'b' : 'q',
	'c' : '\u0254', //open o -- from pne
	'd' : 'p',
	'e' : '\u01DD',
	'f' : '\u025F', //from pne
	'g' : '\u0253', // by bacek // '\u0183',
	'h' : '\u0265',
	'i' : '\u1D09',
	// 'i' : '\u0131', //from pne
	'j' : '\u027E',
	'k' : '\u029E',
	//l : '\u0283',
	'm' : '\u026F',
	'n' : 'u',
	'r' : '\u0279',
	't' : '\u0287',
	'v' : '\u028C',
	'w' : '\u028D',
	'y' : '\u028E',
	'.' : '\u02D9',
	'[' : ']',
	'(' : ')',
	'{' : '}',
	'?' : '\u00BF', //from pne
	'!' : '\u00A1',
	// "\'" : ',',
	',' : '\u2018', // mblsha
	'<' : '>',
	'_' : '\u203E',
	';' : '\u061B',
	'\u203F' : '\u2040',
	'\u2045' : '\u2046',
	'\u2234' : '\u2235',

// by mblsha
	'&' : '\u214B',
	'A' : '\u2200',
	'D' : '\u2acf',
	'E' : '\u018E',
	'F' : '\u2132',
	'G' : '\u2141',
	'L' : '\u2142',
	'M' : '\u019C',
	'V' : '\u039b',
	'Y' : '\u2144',
	'R' : '\u1D1A',

	// russian
	'\u0430' : '\u0250', // а
	'\u0431' : '\u018D', // б
	// '\u0437' : '\u1D08' // з
	'\u041f' : '\u2a06' // П
}

for (i in flipTable) {
	flipTable[flipTable[i]] = i
}

</script>
	</head>
	<body>
		<h1>
			Flip
		</h1>
		<form name="f" id="f">
			Original: 
			<textarea rows="5" cols="50" name="original" onkeyup="flip()">
</textarea><input type="button" value="Flip" onclick="flip()"><br>
			Flipped: 
			<textarea rows="5" cols="50" name="flipped">
</textarea>
		</form>
		<p style="width:300px">
			<b>mblsha: stolen from http://www.revfad.com/flip.html</b><br>
			<small>I got the idea to do this from pne's post at <a href="http://pne.livejournal.com/398399.html">http://pne.livejournal.com/398399.html</a>. Thank you to Brook Monroe, Tim McCormack, and Glards amongst others for further suggestions.<br>
			<a href="oldflip.html">previous version</a> <a href="http://www.revfad.com/">Reverse Fad Productions</a></small>
		</p>
	</body>
</html>
